<!DOCTYPE HTML>
<html lang="en">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="ES6的基础语法新特性, Casey Lu&#39;s Blog">
    <meta name="description" content="">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>ES6的基础语法新特性 | Casey Lu&#39;s Blog</title>
    <link rel="icon" type="image/png" href="/medias/maozhao.png">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/all.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">

    <script src="/libs/jquery/jquery.min.js"></script>
    
<meta name="generator" content="Hexo 4.2.0"><link rel="alternate" href="/atom.xml" title="Casey Lu's Blog" type="application/atom+xml">
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>


<body>
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">Casey Lu's Blog</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>Index</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>Tags</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>Categories</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>Archives</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>About</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="Search" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">Casey Lu's Blog</div>
        <div class="logo-desc">
            
            Never really desperate, only the lost of the soul.
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			Index
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			Tags
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			Categories
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			Archives
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			About
		</a>
          
        </li>
        
        
    </ul>
</div>

        </div>

        
    </nav>

</header>

    
<script src="/libs/cryptojs/crypto-js.min.js"></script>
<script>
    (function() {
        let pwd = '';
        if (pwd && pwd.length > 0) {
            if (pwd !== CryptoJS.SHA256(prompt('嘻嘻嘻，访问本文章需要密码')).toString(CryptoJS.enc.Hex)) {
                alert('密码错误哦~');
                location.href = '/';
            }
        }
    })();
</script>




<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/articleimages/23.jpg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <h1 class="description center-align post-title">ES6的基础语法新特性</h1>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        width: 345px;
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content {
        height: calc(100vh - 250px);
        overflow: auto;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/Javascript/">
                                <span class="chip bg-color">Javascript</span>
                            </a>
                        
                            <a href="/tags/ES6/">
                                <span class="chip bg-color">ES6</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/%E6%8A%80%E6%9C%AF%E5%88%86%E4%BA%AB/" class="post-category">
                                技术分享
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>Publish Date:&nbsp;&nbsp;
                    2020-03-09
                </div>
                

                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>Word Count:&nbsp;&nbsp;
                    3.4k
                </div>
                

                

                
            </div>

        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <p>ES6语法在面试中是频繁被提及的，相比于ES3和ES5它具备许多<img class="emoji" draggable="false" alt="🆕" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f195.png"/>特性，接下来，主要通过对比将从多个方面逐个介绍它的新特性。</p>
<h2 id="一、常量定义">一、常量定义</h2>
<p>在ES3中不存在常量的定义，ES5中可以实现，但并未明确的定义，通过对象添加属性prototype实现，Object.defineProperty，在ES6中，提出了<code>let</code>和<code>const</code></p>
<p><strong>1. let</strong></p>
<ul>
<li>let作用域只限于当前代码块</li>
<li>let声明的变量作用域不会被提升</li>
<li>在相同的作用域下不能声明相同的变量</li>
<li>for循环体现let父子作用域</li>
</ul>
<p><strong>2. const</strong></p>
<ul>
<li>const作用域只限于当前的代码块</li>
<li>const声明变量作用域不会被提升</li>
<li>在相同的作用域下不能重复声明</li>
<li>声明的同时必须赋值，声明之后的值无法改变</li>
</ul>
<p><strong>3. var、let、const三者对比</strong></p>
<table>
<thead>
<tr>
<th>var</th>
<th>let</th>
<th>const</th>
</tr>
</thead>
<tbody>
<tr>
<td>全局、整个函数块</td>
<td>块级变量</td>
<td>块级变量</td>
</tr>
<tr>
<td>存在变量的提升</td>
<td>允许重新赋值</td>
<td>不允许重新赋值</td>
</tr>
</tbody>
</table>
<h2 id="二、数据类型">二、数据类型</h2>
<p>首先回忆一下Js中的数据类型<img class="emoji" draggable="false" alt="📝" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f4dd.png"/><br>
<strong>基本数据类型</strong>：Number, Boolean,String,Null,Undefined (变量值存储于栈中)<br>
<strong>引用数据类型</strong>：Array, Object,Function（对象存储于堆中，对象的地址存在栈中）<br>
在函数调用的过程中，都是传递栈中的内容，基本数据类型传递的是变量的值，引用数据类型传递的是对象的地址</p>
<p><strong>1.ES6新增的数据类型： Symbol</strong></p>
<blockquote>
<p>ES5对象中的属性名都是字符串，容易造成属性冲突；<br>
ES6引入了新的原始数据类型<strong>Symbol</strong>,表示独一无二的值</p>
</blockquote>
<p>因此设置Object对象的属性名有两种方式：一是字符串，二是Symbol</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">let str1 = Symbol()
let str2 = Symbol()
console.log(str1 === str2) // false，每个都独一无二
console.log(typeof(str1)) // Symbol

// Symbol主要用于对象属性的定义，且属性是唯一的
const obj = {}
obj[Symbol("name")] = "Mike"
obj[Symbol("name")] = "Casey"
console.log(obj) // {Symbol(name):"Mike",Symbol(name):"Casey"}
</code></pre>
<p><strong>2.数据集合Set</strong></p>
<p><img src="https://img-blog.csdnimg.cn/2020030915574632.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM0ODczNzEw,size_16,color_FFFFFF,t_70" alt="Set数据集合的特性"></p>
<p>使用示例：</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">let set  = new Set(['Juidy','Juidy','Lisa','Davie'])
console.log(set) // Juidy, Lisa, Davie
console.log(set.size) // 3
set.add('Gier')
set.delete('Lisa')
set.has('Yumy') // false
set.clear()
</code></pre>
<p><strong>3.数据集合Map</strong></p>
<p><img src="https://img-blog.csdnimg.cn/20200309161056893.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM0ODczNzEw,size_16,color_FFFFFF,t_70" alt="Map数据集合的特性"></p>
<p>使用示例：</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">let obj1 = {height:'cm'}
let obj2 = {weight:'kg'}
const map = new Map([
  ['name', 'Twitter'],
  ['age', 20],
  ['sex','male'],
  [obj1,183],
  [onb2,68]
])
console.log(map) 
// Map {  'name' => 'Twitter',  'age' => 20,  'sex' => 'male',  { height: 'cm' } => 183,  { weight: 'kg' } => 68 }
console.log(map.size) // 5, 即不重复的key的个数
// 设置值和获取值
console.log(map.set('age',21))
console.log(map.get('age'))
// Map自带的获取键，值以及键值对hash关系的方法
console.log(map.keys())
// [Map Iterator] { 'name', 'age', 'sex', { height: 'cm' }, { weight: 'kg' } }
console.log(map.values())
// [Map Iterator] { 'Twitter', 21, 'male', 183, 68 }
console.log(map.entries())
// [Map Iterator] {  [ 'name', 'Twitter' ],  [ 'age', 21 ],  [ 'sex', 'male' ],  [ { height: 'cm' }, 183 ],  [ { weight: 'kg' }, 68 ] }
</code></pre>
<h2 id="三、解构赋值">三、解构赋值</h2>
<p>ES6允许按照一定的模式从数组和对象中提取值，对变量进行赋值，这被称为<strong>解构</strong><img class="emoji" draggable="false" alt="💥" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f4a5.png"/><br>
<strong>1. 基本用法：</strong></p>
<pre class=" language-language-javascript"><code class="language-language-javascript">let [name,age,sex] = ["Casey",23,"female"]
// 等价于,传统定义
let name = "Casey"
let age = 23
let sex = "female"
</code></pre>
<p><strong>2.支持解构赋值的数据类型</strong><br>
1） 对象<br>
2） 嵌套数组<br>
3） 字符串<br>
4） 空缺变量  <code>let [a,b,,e] = ['Addy','Bob',[1,2],4]</code><br>
5） 多余变量  <code>let [a,b,,e,f] = ['a','b',[3,4],5]</code></p>
<p><img class="emoji" draggable="false" alt="✏️" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/270f.png"/>: 因为字符串有解构器，所以可以解析出来</p>
<h2 id="四、块级作用域">四、块级作用域</h2>
<p>JS中的两种作用域是：全局作用域和函数作用域<br>
我们知道，在JS中所有通过var声明的变量都会提升到当前作用域的最前面，也就是上面提到的var所实现的变量提升。如下<img class="emoji" draggable="false" alt="👇" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f447.png"/>：</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">function funC(){
  console.log(temp)
  var temp
}
</code></pre>
<p>正因为变量提升的存在，使得JS本身并不像类C语言一样支持块状作用域，根据我们的编码习惯，我们并不喜欢变量提升机制，而是鞥希望代码能按照顺序执行。因此神奇的ES6引入了<strong>块级作用域</strong>，并且采用了<code>let、const</code>来支持块级作用域。</p>
<p><strong>优势：</strong> 在循环中使用let来代替var可以在循环结束的时候销毁变量，避免无用的变量影响全局，安全明了，利用块级作用域可以实现累加器</p>
<p>Tips: 在ES6中最好使用函数表达式来表示一个函数，ES6中允许函数在块级作用域中可以声明的条件必须是在大括号里面，否则会报错</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">//函数声明报错
{
  if(2 < 4){
    function fn(){
      console.log('I’m here！')
    }
  }
}
fn()  // Uncaught TypeError: fn is not a function
//正确的函数声明
{
  let fa = '111'
  let fn = function(){
    console.log('I’m here！')
  }
  console.log(fa, fn) // 111 f(){ console.log('I’m here！')}
}
</code></pre>
<blockquote>
<p>使用块级绑定的最佳实践是：默认使用 <code>const</code> ，只在确定需要改变变量的值时，使用 <code>let</code> ，可以确保基本层次的不可变性，以最大化地避免错误的产生。</p>
</blockquote>
<h2 id="五、箭头函数">五、箭头函数 =&gt;</h2>
<p>在ES6中引入了箭头函数 <a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Functions/Arrow_functions" target="_blank" rel="noopener">(MDN 箭头函数)</a>，<code>let func  = value =&gt; value+1</code></p>
<p><strong>1.箭头函数与普通函数的区别：</strong></p>
<ul>
<li><img class="emoji" draggable="false" alt="❌" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/274c.png"/>箭头函数没有<code>this</code>,需要查找作用域链来确定this的值?<br>
(如果它被非箭头函数包含，则this绑定的就是最近一层的非箭头函数的this), 箭头函数this是父作用域的<code>this</code>,不是调用时的<code>this</code></li>
<li><img class="emoji" draggable="false" alt="❌" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/274c.png"/>箭头函数没有自己的<code>arguments</code>对象，但是可以访问外围函数的arguments对象,也没有<code>caller,calee</code></li>
<li><img class="emoji" draggable="false" alt="❌" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/274c.png"/>箭头函数不能作为构造函数，不能通过<code>new</code>关键词调用，同样也没有new.target值和原型属性</li>
<li><img class="emoji" draggable="false" alt="❌" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/274c.png"/>箭头函数通过<code>call</code>和<code>apply</code>来调用，不会改变<code>this</code>的指向，只会传入参数</li>
<li><img class="emoji" draggable="false" alt="❌" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/274c.png"/>箭头函数不能作为<code>Generator</code>函数，不能使用<code>yield</code>关键字</li>
</ul>
<p>此外还有一些特性：</p>
<ul>
<li>箭头函数返回对象时，要加一个小括号<code>var func = () =&gt;({  foo: 1 })</code></li>
<li>箭头函数在ES6 class中声明的方法为实例方法，不是原型方法</li>
<li>多重箭头函数就是高阶函数，相当于内嵌函数</li>
</ul>
<p>提到箭头函数和<code>this</code>,还有一个非常重要的问题必须有姓名 <strong>this的绑定方式</strong></p>
<p><strong>2.this的四种绑定方式：</strong></p>
<ul>
<li><strong>默认绑定</strong>：全局环境中，this默认绑定到<code>window</code>对象上</li>
<li><strong>隐式绑定</strong>：被直接对象所包含的函数调用（方法调用）时，this隐式绑定到该直接对象上（隐式丢失是指被隐式绑定的函数丢失绑定对象，默认绑定到window）</li>
<li><strong>显式绑定</strong>：通过<code>call(),apply(),bind()</code>方法将对象绑定到this上</li>
<li><strong>new绑定</strong>：如果函数或方法调用之前带有关键字<code>new</code>,就构成构造函数调用。<br>
<img src="https://img-blog.csdnimg.cn/20200309221312734.png" alt="构造函数绑定"></li>
</ul>
<p>关于this绑定，这一篇就不再过多赘述，想看详细的this绑定可以读一下<img class="emoji" draggable="false" alt="👉" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f449.png"/><a href="https://www.cnblogs.com/luoyanan/p/11922483.html" target="_blank" rel="noopener">this的绑定方式总结</a></p>
<h2 id="六、扩展功能">六、扩展功能</h2>
<p>ES6语法可以更好地支持扩展功能，包含数组、对象以及函数的扩展，此外ES6中出现了延展符…,既可以用来定义数组，还能扩展数组、对象，函数</p>
<p><strong>一、数组的扩展</strong></p>
<p><strong>1.Array.from——实现非数组list的转化</strong></p>
<pre class=" language-language-javascript"><code class="language-language-javascript">let list = document.querySelectorAll("li")
console.log(Array.isArray(list)) // false
let newList = Array.from(list)
console.log(Array.isArray(newList)) // true
</code></pre>
<p><strong>2.Array.of——零散元素转化为数组</strong><br>
转化方式：<code>Array.of( 1, 3, 7, 9)</code></p>
<p><strong>3. 延展符…</strong></p>
<pre class=" language-language-javascript"><code class="language-language-javascript">// 用延展符来定义数组
let str = "Kole";
let strArr =[...str];
console.log(Array.isArray(strArr));  //true
</code></pre>
<p><strong>二、对象的扩展</strong></p>
<p><strong>1.ES6中key和value一样时，定义对象时只需要写一个就可以</strong></p>
<pre class=" language-language-javascript"><code class="language-language-javascript">let name = 'Peter'
let age = 19
let obj = {
  name,
  age
}
console.log(obj) // {name:'Peter', age:19}
</code></pre>
<p><strong>2.assign的用法</strong></p>
<pre class=" language-language-javascript"><code class="language-language-javascript">let obj1 = {name: "Lisa"}
let obj2 = {age: 37}
let obj = {}
Object.assign(obj, obj1, obj2) // 将obj1，obj2合并到obj上
console.log(obj) // {name:"Lisa", age:37}
</code></pre>
<p><strong>3. 将Set对象转为Array</strong></p>
<p>主要用于<strong>数据传递</strong>和<strong>数组去重</strong>，因为Set具有<strong>唯一性</strong><img class="emoji" draggable="false" alt="✔️" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/2714.png"/></p>
<pre class=" language-language-javascript"><code class="language-language-javascript">let myArr = [1, 2, 10, "ZS", 20, 2, 1]
console.log(new Set(myArr)) // 根据set唯一性去重复
let newArr = [...new Set(myArr)] // 将set转化为array
console.log(Array.isArray(newArr)) // true
</code></pre>
<p><strong>三、函数的扩展</strong></p>
<p><strong>1. 在ES6中，形参可以设置默认值</strong><br>
<code>let func = function(a = 1, b = 2){ return a+b }</code><br>
<strong>2. 参数形式：可以用延展操作符…代替</strong><br>
<img class="emoji" draggable="false" alt="🅰️" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f170.png"/>可变参数…a, 在不清楚元素个数的时候可以表示如此<br>
<img class="emoji" draggable="false" alt="🅱️" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f171.png"/>可以使用扩展运算符…来合并数组，如<code>b = [10,19], a = [1,2...b]</code></p>
<pre class=" language-language-javascript"><code class="language-language-javascript">// 在不清楚元素个数时，可以使用延展操作符代替
function sum (name, ...nums){
  console.log(name)
  let res = 0
  for(let value of nums){
    res += value
  }
  return res
}
console.log(sum("Juilian",2,34,6,19)) // Juilian 61
</code></pre>
<h2 id="七、对象代理——Proxy">七、对象代理——Proxy</h2>
<p>ES6中新添加了对象代理<strong>Proxy</strong><br>
<strong>Proxy是什么</strong><img class="emoji" draggable="false" alt="❓" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/2753.png"/> <a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Proxy" target="_blank" rel="noopener">MDN Proxy</a><br>
代理Proxy是一个<strong>构造函数</strong>（target, handler），返回一个代理对象Proxy,主要用于<strong>从外部控制对对象内部的访问</strong>。<br>
<strong>本质：</strong> 元编程非破坏性数据劫持。在原对象的基础上进行功能的衍生而且又不影响原对象，符合高内聚低耦合的设计理念</p>
<ul>
<li><code>target</code>接收Proxy()转发的所有内部方法</li>
<li><code>handler</code>可以覆写（overwrite）任意代理的内部方法。<br>
总之，调用Proxy的方法就会调用target上对应的方法，外界每次通过Proxy访问target对象的属性时，都会经过handler对象</li>
</ul>
<blockquote>
<p>总之，Proxy就是在数据外层套了一个壳，然后通过这个壳访问内部数据</p>
</blockquote>
<p><strong>1. Proxy的作用：</strong><br>
对对象进行拦截、实现对数据读取、修改的过滤保护</p>
<table>
<thead>
<tr>
<th>语法</th>
<th>对象操作</th>
</tr>
</thead>
<tbody>
<tr>
<td>ES3</td>
<td>设局部变量，采用<strong>闭包</strong>方式的set和get方法</td>
</tr>
<tr>
<td>ES5</td>
<td>采用对象下面的<strong>Object.defineProperty()</strong> 对属性描述符进行操作</td>
</tr>
<tr>
<td>ES6</td>
<td>使用<strong>Proxy代理对象</strong>，设计与实现具备set和get方法的新对象</td>
</tr>
</tbody>
</table>
<p><strong>2. Proxy使用方法：</strong><br>
第一个参数：要拦截的对象，第二个参数：对象（内部有set和get）</p>
<blockquote>
<p>get()——对象读数据的时候调用，两个参数：target(目标数据)和key(所读数据的key)<br>
set()——对象设置数据时触发，内部三个形参：target, key 和 value</p>
</blockquote>
<p>用法示例：</p>
<pre class=" language-language-javascript"><code class="language-language-javascript">var Person = {
  name:'Lily',
  age: 17,
  sex: 'female'
}
var p = new Proxy(Person,{
  get(target, key){
    return target[key]
  }
  set(target, key, value){
    if(key !== 'sex'){ // 设置Person对象的sex属性不可修改
      target[key] = value
    }
  }
})
console.log(p.name, p.age, p.sex) // Lily,17,female
// 重新设置对象属性
p.name = "Lisa"
p.age = 25
p.sex = 'male' // Person对象中的sex属性不可以设置
console.log(p.name, p.age, p.sex) // Lisa,25,female
</code></pre>
<p>不仅是set和get, Proxy有13种数据劫持的操作：<br>
<img src="https://img-blog.csdnimg.cn/20200309200446373.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM0ODczNzEw,size_16,color_FFFFFF,t_70" alt="Proxy中的处理方法"></p>
<p><strong>3.Proxy的应用</strong></p>
<ul>
<li>封装高阶函数，为函数添加特定的功能</li>
<li>代理对象的访问</li>
<li>作为胶水桥接不同结构的对象</li>
<li>监视对象的变化</li>
<li>Proxy对象可以拦截目标对象的任意属性，这使得它很适合来编写web服务的客户端</li>
<li>Proxy可以用来实现数据层的ORM（Object-Relationship-Model）层</li>
<li>在Vue 3.0中使用了Proxy去实现部分核心代码</li>
<li>在业务开发时应该注意Proxy使用场景，当对象的功能变得复杂或者我们需要进行一定的访问限制时，便可以考虑使用代理。</li>
</ul>
<p><strong>4. Proxy的优劣势</strong><br>
在ES5中，虽然使用<code>Object.defineProperty()</code>实现属性已经非常的简单，但是在设置对象属性为不可写属性的时候，修改并不成功。相对于ES3和ES5，ES6中使用Proxy是非常便利的，因为可以在set和get里面做出更多的逻辑处理<br>
<strong>优势：</strong></p>
<ul>
<li>Proxy让开发者很方便的使用代理模式，使函数更加强大，业务逻辑更加清楚</li>
<li>不但可以取代<code>Object.defineProperty()</code>，并且还扩增了非常多的功能</li>
<li>Proxy技术支持检测数组的push等方法操作，支持对象属性的动态添加和删除，极大地简化了响应化的代码量</li>
</ul>
<p><strong>缺点：</strong></p>
<ul>
<li>运行环境必须支持ES6</li>
<li>兼容性一般，（不过谷歌开发的proxy-polyfill目前已经支持get、set、apply、construct 到ie9了）</li>
<li>不能直接代理一些需要this的对象，代理之后行为可能发生变化，可能需要手动绑定this</li>
<li>性能比较差，但是因浏览器而异，proxy绝对不适合用在性能关键点的代码上，当然，也可以衡量proxy带来的遍历和可能损耗的性能，进行合理的中和，来达到最佳的开发体验和用户体验</li>
</ul>
<blockquote>
<p>目前浏览器没有办法判断对象是否被代理，但是在node版本10以上，可以使用<code>util.types.isProxy</code>来判断</p>
</blockquote>
<h2 id="八、其他">八、其他</h2>
<ol>
<li>除此之外，ES6中还新增了<code>class</code>语法糖<img class="emoji" draggable="false" alt="🍭" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f36d.png"/><br>
<strong>作用：</strong> 让对象原型的写法更加清晰，更像面向对象的编程方式，也是构造函数的另一种写法。</li>
</ol>
<pre class=" language-language-javascript"><code class="language-language-javascript">//ES6之前的构造函数写法
function Person(name, age){
  this.name = name
  this.age = age
}
Person.prototype = {
  constructor: Person,
  print(){
    console.log('Hi! My name is '+this.name,',and I\'m ' + this.age + ' years old.')
  }
}
// class面向对象写法
class Person{
  constructor(name,age){
    this.name = name
    this.age = age
  }
  print(){
    console.log('Hi! My name is '+this.name,',and I\'m ' + this.age + ' years old.')
  }
}
// 定义和调用类方法
let person = new Person("Rose",24)
person.print() // Hi! My name is Rose,and I'm 24 years old
</code></pre>
<ol start="2">
<li>ES6中也支持<strong>模板字符串</strong> <img class="emoji" draggable="false" alt="🍡" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f361.png"/><br>
<strong>作用：</strong> 使用 <strong>``</strong> 符号定义模板，在里面使用<code>${}</code>的形式调用变量，就可以实现代码的格式化，类似render（）函数, 在 Vue 中常用</li>
</ol>
<pre class=" language-language-javascript"><code class="language-language-javascript">let name = "dance";
let content= "Coincidance"
let html = `<html>              
              <head>You can really Dance!<meta name="generator" content="Hexo 4.2.0"><link rel="alternate" href="/atom.xml" title="Casey Lu's Blog" type="application/atom+xml">
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>              
                <p class="${name}"> ${content} </p>
            </html>`           
           //这里使用${}的形式调用变量
console.log(html);
</code></pre>
<p>ES6语法带来了许多新的特性，目前也已经有非常成熟的使用，学习ES6语法可以帮助我们更好地了解JS<img class="emoji" draggable="false" alt="😄" src="https://twemoji.maxcdn.com/v/12.1.5/72x72/1f604.png"/></p>
<p>最后，附上一个ES6的特性小字典，来源于IQ前端的原创文章配图：<br>
<img src="https://img-blog.csdnimg.cn/20200317150232419.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzM0ODczNzEw,size_16,color_FFFFFF,t_70" alt="ES6特性梳理图"></p>

            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        Author:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://caseylu.gitee.io" rel="external nofollow noreferrer">Casey Lu</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        Link:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="https://caseylu.gitee.io/2020/03/09/8-es6-de-ji-chu-yu-fa-xin-te-xing/">https://caseylu.gitee.io/2020/03/09/8-es6-de-ji-chu-yu-fa-xin-te-xing/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        Reprint policy:
                    </i>
                </span>
                <span class="reprint-info">
                    All articles in this blog are used except for special statements
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    reprint polocy. If reproduced, please indicate source
                    <a href="https://caseylu.gitee.io" target="_blank">Casey Lu</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>Copied successfully, please follow the reprint policy of this article</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">more</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/Javascript/">
                                    <span class="chip bg-color">Javascript</span>
                                </a>
                            
                                <a href="/tags/ES6/">
                                    <span class="chip bg-color">ES6</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    
    <div class="social-share" data-sites="google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.4rem;
        line-height: 38px;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fas fa-times"></i></a>
            <h4 class="reward-title">谢谢大佬的小鱼干，喵~</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微 信</a></li>
                    </ul>
                    <div id="alipay">
                        <img src="/medias/reward/alipay.jpg" class="reward-img" alt="支付宝打赏二维码">
                    </div>
                    <div id="wechat">
                        <img src="/medias/reward/wechat.png" class="reward-img" alt="微信打赏二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>
            
        </div>
    </div>

    
        <link rel="stylesheet" href="/libs/gitalk/gitalk.css">
<link rel="stylesheet" href="/css/my-gitalk.css">

<div class="card gitalk-card" data-aos="fade-up">
    <div class="comment_headling" style="font-size: 20px; font-weight: 700; position: relative; left: 20px; top: 15px; padding-bottom: 5px;">
        <i class="fas fa-comments fa-fw" aria-hidden="true"></i>
        <span>评论</span>
    </div>
    <div id="gitalk-container" class="card-content"></div>
</div>

<script src="/libs/gitalk/gitalk.min.js"></script>
<script>
    let gitalk = new Gitalk({
        clientID: 'b739596984975414aa79',
        clientSecret: 'c5792bc3376f951910111f232176fbadfa919286',
        repo: 'L0ittle.github.io',
        owner: 'L0ittle',
        admin: "L0ittle",
        id: '2020-03-09T21-40-36',
        distractionFreeMode: false  // Facebook-like distraction free mode
    });

    gitalk.render('gitalk-container');
</script>
    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;Previous</div>
            <div class="card">
                <a href="/2020/03/10/9-javascript-bi-shi-shua-ti-xiao-jie-er/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/articleimages/5.jpg" class="responsive-img" alt="JavaScript笔试刷题小结（二）">
                        
                        <span class="card-title">JavaScript笔试刷题小结（二）</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            继续整理最近的刷题记录
1. 剑指Offer 39. 数组中出现次数过半的数字
书中提到了两种复杂度均为O(n)的解法：
1）基于Partition函数：
如果这个数字存在，那它必然是数组排序后的中位数，基于随机快排中的Partition的
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2020-03-10
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E7%AC%94%E8%AF%95%E9%9D%A2%E8%AF%95/" class="post-category">
                                    笔试面试
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/Javascript/">
                        <span class="chip bg-color">Javascript</span>
                    </a>
                    
                    <a href="/tags/Leetcode/">
                        <span class="chip bg-color">Leetcode</span>
                    </a>
                    
                    <a href="/tags/%E7%AE%97%E6%B3%95/">
                        <span class="chip bg-color">算法</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                Next&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2020/03/08/7-cbu-ji-zhu-bu-mian-shi-zong-jie-chi-xu-geng-xin/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/articleimages/3.jpg" class="responsive-img" alt="CBU技术部面试总结（持续更新）">
                        
                        <span class="card-title">CBU技术部面试总结（持续更新）</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            一、在线测评
时间： 03月05日 7:30pm-9:30pm
内容： 在上一次的《JS笔试刷题小结》中已经提到了，不再过多说明
二、一面
时间： 03月07日 8:30pm-9:00pm
题外话: 当晚事发突然，在完全没有约时间的情况下，
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2020-03-08
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E7%AC%94%E8%AF%95%E9%9D%A2%E8%AF%95/" class="post-category">
                                    笔试面试
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/Javascript/">
                        <span class="chip bg-color">Javascript</span>
                    </a>
                    
                    <a href="/tags/CSS/">
                        <span class="chip bg-color">CSS</span>
                    </a>
                    
                    <a href="/tags/ES6/">
                        <span class="chip bg-color">ES6</span>
                    </a>
                    
                    <a href="/tags/Vue/">
                        <span class="chip bg-color">Vue</span>
                    </a>
                    
                    <a href="/tags/HTTP/">
                        <span class="chip bg-color">HTTP</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>


<script>
    $('#articleContent').on('copy', function (e) {
        // IE8 or earlier browser is 'undefined'
        if (typeof window.getSelection === 'undefined') return;

        var selection = window.getSelection();
        // if the selection is short let's not annoy our users.
        if (('' + selection).length < Number.parseInt('100')) {
            return;
        }

        // create a div outside of the visible area and fill it with the selected text.
        var bodyElement = document.getElementsByTagName('body')[0];
        var newdiv = document.createElement('div');
        newdiv.style.position = 'absolute';
        newdiv.style.left = '-99999px';
        bodyElement.appendChild(newdiv);
        newdiv.appendChild(selection.getRangeAt(0).cloneContents());

        // we need a <pre> tag workaround.
        // otherwise the text inside "pre" loses all the line breaks!
        if (selection.getRangeAt(0).commonAncestorContainer.nodeName === 'PRE') {
            newdiv.innerHTML = "<pre>" + newdiv.innerHTML + "</pre>";
        }

        var url = document.location.href;
        newdiv.innerHTML += '<br />'
            + 'From: Casey Lu&#39;s Blog<br />'
            + 'Author: Casey Lu<br />'
            + 'Link: <a href="' + url + '">' + url + '</a><br />'
            + '本文章著作权归作者所有，任何形式的转载都请注明出处。';

        selection.selectAllChildren(newdiv);
        window.setTimeout(function () {bodyElement.removeChild(newdiv);}, 200);
    });
</script>


<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>


<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>


    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;TOC</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            collapseDepth: Number('0'),
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>



    <footer class="page-footer bg-color">
    
        <link rel="stylesheet" href="/libs/aplayer/APlayer.min.css">
<div class="">
    
    <div class="row">
        <meting-js class="col l8 offset-l2 m10 offset-m1 s12"
                   server="netease"
                   type="playlist"
                   id="4892766072"
                   fixed='true'
                   autoplay='false'
                   theme:='#42b983'
                   loop='all'
                   order='random'
                   preload='auto'
                   volume='0.7'
                   list-folded='true'
        >
        </meting-js>
    </div>
</div>

<script src="/libs/aplayer/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

    
    <div class="container row center-align" style="margin-bottom: 0px !important;">
        <div class="col s12 m8 l8 copy-right">
            Copyright&nbsp;&copy;
            <span id="year">2020</span>
            <a href="https://caseylu.gitee.io" target="_blank">Casey Lu</a>
            |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
            |&nbsp;Theme&nbsp;<a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">Matery</a>
            <br>
            
            &nbsp;<i class="fas fa-chart-area"></i>&nbsp;站点总字数:&nbsp;<span
                class="white-color">63.2k</span>&nbsp;字
            
            
            
            
            
            
            <span id="busuanzi_container_site_pv">
                |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span id="busuanzi_value_site_pv"
                    class="white-color"></span>&nbsp;次
            </span>
            
            
            <span id="busuanzi_container_site_uv">
                |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span id="busuanzi_value_site_uv"
                    class="white-color"></span>&nbsp;人
            </span>
            
            <br>
            
            <br>
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/L0ittle" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:caseylu119@163.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>







    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=1351238945" class="tooltipped" target="_blank" data-tooltip="QQ联系我: 1351238945" data-position="top" data-delay="50">
        <i class="fab fa-qq"></i>
    </a>







    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>

</div>
    </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;Search</span>
            <input type="search" id="searchInput" name="s" placeholder="Please enter a search keyword"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="/libs/materialize/materialize.min.js"></script>
    <script src="/libs/masonry/masonry.pkgd.min.js"></script>
    <script src="/libs/aos/aos.js"></script>
    <script src="/libs/scrollprogress/scrollProgress.min.js"></script>
    <script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Global site tag (gtag.js) - Google Analytics -->


    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    

    

    
    
    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
